package com.zengjianjun.es.demo.highlevelclient.listener;

import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.index.reindex.BulkByScrollResponse;

/**
 * @author zengjianjun
 */
@Slf4j
public class GaidListener implements ActionListener<BulkByScrollResponse> {

    @Override
    public void onResponse(BulkByScrollResponse bulkByScrollResponse) {
        log.info("GaidListener, took = {} , total = {} , updated = {} , reasonCancelled = {}",
                bulkByScrollResponse.getTook(),
                bulkByScrollResponse.getTotal(),
                bulkByScrollResponse.getUpdated(),
                bulkByScrollResponse.getReasonCancelled());
    }

    @Override
    public void onFailure(Exception e) {
        log.error("GaidListener Exception : ", e);
    }

    public static GaidListener build() {
        return new GaidListener();
    }
}
